package com.woniu.elderly.operation.exception;

import com.woniu.common.entity.ResponseResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.HashMap;
import java.util.Map;

//统一异常处理，底层是拦截器
@Slf4j    //打印异常
@RestControllerAdvice
public class GlobalException {

    //处理已点赞异常
    @ExceptionHandler   //默认省略(Exception.class)
    public ResponseResult doAlreadyLikedException(AlreadyLikedException e){
        //查看异常类
        log.info("exception-class:"+e.getClass());
        //查看异常消息
        log.info("exception-message:"+e.getMessage());
        return new ResponseResult<>(303,e.getMessage(),null);
    }



}
